import { axios, get, post, Delete, Patch } from './request'

// 封装所有的接口API
// 反向代理 

export const ajax = {
  getword: () => get('/word'),

  findUser: (params) => get('/users', params),

  addUser: (data) => post('/users', data),

  // 修改密码
  updatePassword: (id, data) => Patch('/users/'+id, data),

  // 发送验证码 网易云接口 一天5次免费
  sendCaptcha: (params) => get('http://47.104.209.44:3333/captcha/sent', params),

  // 校验验证码
  verifyCaptcha: (params) => get('http://47.104.209.44:3333/captcha/verify', params),

  // 蔚蓝书城swipe接口
  getWeiLanSwipe: (params) => get('https://www.welan.com/mobile/home/swipe', params),

  // 蔚蓝书城首页推荐+编辑推荐接口
  getWeiLanHome: (params) => get('https://www.welan.com/mobile/home/modal', params),

  // 蔚蓝书城首页精品推荐接口
  getRecommendList: (params) => get('https://www.welan.com/mobile/home/recommendList', params),

  // 详情页
  getDetails: (params) => get('https://www.welan.com/mobile/book/detail', params),

  // 点赞
  getPraiseOne: (params) => get('/praises', params),

  // 添加
  addPraiseOne: (params) => post('/praises', params),

  // 删除
  removePraiseOne: (id) => Delete('/praises/'+id),

  // 加入购物车
  getCartOne: (params) => get('/carts', params),

  // 修改商品数量
  updateBookNumber: (id, data) => Patch('/carts/'+id, data),

  // 添加
  addCartOne: (params) => post('/carts', params),

  // 删除
  removeCartOne: (id) => Delete('/carts/'+id),

  // 收藏
  getCollectOne: (params) => get('/collects', params),

  // 添加
  addCollectOne: (params) => post('/collects', params),

  // 删除
  removeCollectOne: (id) => Delete('/collects/'+id),

  // 地址
  getAddress: (params) => get('/address', params),

  // 添加
  addAddress: (data) => post('/address', data),

  // 删除
  removeAddress: (params) => get('/address', params),

}